﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using LogManager.Base;
using LogManager.Config.Event;
using LogManager.Base.Models;

namespace LogManager.Config
{
    public class EventTypeConfiguration : ConfigurationElement, IEventType
    {
        /// <summary>
        /// Type Id of the event type (e.g. 1309)
        /// </summary>
        [ConfigurationProperty("typeId", IsKey = true)]
        public string TypeId
        {
            get { return (string)this["typeId"]; }
            set { this["typeId"] = value; }
        }

        [ConfigurationProperty("properties", IsRequired = false)]
        public EventPropertyCollection EventPropertyCollection
        {
            get { return (EventPropertyCollection)this["properties"]; }
            set { this["properties"] = value; }
        }


        public IEnumerable<string> CommonProperties
        {
            get
            {
                return this.EventPropertyCollection.Cast<EventPropertyConfiguration>().Select(pc => pc.PropertyName);
            }
        }
    }

}
